<template>
    <div class="module-wrap">
      <el-descriptions :column="2" border>
        <el-descriptions-item label="名称">{{ mother?.name || '-' }}</el-descriptions-item>
        <el-descriptions-item label="编码">{{ mother?.code || '-' }}</el-descriptions-item>
        <el-descriptions-item label="类型">{{ labelByType(mother?.type) }}</el-descriptions-item>
        <el-descriptions-item label="路径" :span="2">
          <el-tooltip :content="fullPath(mother)" placement="top">
            <span class="one-line">{{ fullPath(mother) }}</span>
          </el-tooltip>
        </el-descriptions-item>
        <!-- 你要的“规格/型号/材质/功率/品牌/厂家”等可以继续扩展 -->
      </el-descriptions>
  
      <div class="tool-row">
        <el-button size="small" @click="$emit('open-detail', mother)">详情</el-button>
        <el-button size="small" type="primary" plain @click="$emit('open-edit', mother)">修改</el-button>
        <el-button size="small" type="success" plain @click="$emit('open-add-child', mother)">新增子项</el-button>
        <el-button size="small" @click="$emit('copy-path', mother)">复制路径</el-button>
        <el-button size="small" type="warning" @click="$emit('open-repair-history', mother)">维修历史</el-button>
      </div>
    </div>
  </template>
  
  <script setup>
  const props = defineProps({
    mother: Object,
    descendants: Array,
    fullPath: Function,
  });
  function labelByType(t=''){ 
    const m={MACHINE:'母设备',MODULE:'子设备',COMPONENT:'部件',PART:'零件'};
    return m[String(t).toUpperCase()]||t||'—';
  }
  </script>
  
  <style scoped>
  .module-wrap{ display:grid; gap:12px; }
  .tool-row{ display:flex; gap:8px; }
  .one-line{ display:inline-block; max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  </style>
  